##############################################################################
# Module:  FX_OpenSLIM_GetAssignedSystemMemory
# Version: 3.80b0
# Date:    2009/12/14
# Author:  Carlos Veira Lorenzo - cveira [at] thinkinbig [dot] org
##############################################################################

function FX_OpenSLIM_GetAssignedSystemMemory([bool] $SetConnectToHostByIP, [string] $NodeName, [string] $NodeIP, [string] $PropertyName, [bool] $IsSupported, [bool] $IsString) {
  . $ModulesDir\_SetModuleContext.ps1

  if ( $test ) {
    if ( $NeedCredentials ) {
      Write-Host -foregroundcolor $COLOR_RESULT "Get-WmiObject -ComputerName $TargetNode -Credential $NetworkCredentials -class win32_computersystem -ErrorVariable NodeErrors -ErrorAction silentlycontinue"
    } else {
      Write-Host -foregroundcolor $COLOR_RESULT "Get-WmiObject -ComputerName $TargetNode -class win32_computersystem -ErrorVariable NodeErrors -ErrorAction silentlycontinue"
    }
  } else {
    if ( $NeedCredentials ) {
      $NodeData = Get-WmiObject -ComputerName $TargetNode -Credential $NetworkCredentials -class win32_computersystem -ErrorVariable NodeErrors -ErrorAction silentlycontinue
    } else {
      $NodeData = Get-WmiObject -ComputerName $TargetNode -class win32_computersystem -ErrorVariable NodeErrors -ErrorAction silentlycontinue
    }

    if ( $NodeData -ne $null ) {
      $ErrorFound   = -not $?
      $ErrorText   = $($NodeErrors | Format-List -force * | Out-String)
      $RawOutput   = "$NodeData.TotalPhysicalMemory"
      $ResultValue = "$([math]::Round($($NodeData.TotalPhysicalMemory / $ToGB),2))"

      Write-Host -foregroundcolor $COLOR_RESULT "    + TotalPhysicalMemory: " $ResultValue
    } else {
      Write-Host -foregroundcolor $COLOR_ERROR "    + ERROR: unable to retrieve any information."
      $NodeName >> $FailedNodesFile
    }

    . $ModulesDir\_SaveModuleResults.ps1
  }
}